package com.example.service.impl;

import com.example.mapper.ArticleCategoryMapper;
import com.example.pojo.ArticleCategory;
import com.example.pojo.Author;
import com.example.service.ArticleCategoryService;
import com.example.service.AuthorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
@Slf4j
@Service
public class ArticleCategoryServiceImpl implements ArticleCategoryService {
    @Autowired
    private ArticleCategoryMapper deptMapper;
    @Autowired
    private AuthorService authorService;
    @Override
    public List<ArticleCategory> findAll() {
        return deptMapper.findAll();
    }

    @Override
    public void deleteById(Integer id) {
//        Author e= authorService.getInfo(id);
//      log.info("类{}",e);
//        if(e!=null)
//        {
//            throw new IllegalArgumentException("有人");
//        }

        deptMapper.deleteById(id);
    }

    @Override
    public void insert(ArticleCategory dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.add(dept);
    }

    @Override
    public ArticleCategory getById(Integer id) {
      return  deptMapper.getById(id);
    }

    @Override
    public void update(ArticleCategory dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.updata(dept);
    }
}
